package chenji.gunapi.events;

import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import chenji.gunapi.gun.Gun;



public class GunHitEntityEvent extends Event implements Cancellable {
	private boolean isCanceled;
	private static final HandlerList handlers = new HandlerList();
	private Gun gun;
	private Player damager;
	private double damage;
	private Entity entity;

	public GunHitEntityEvent(Gun gun, Player damager, double damage, Entity entity) {
		this.entity = entity;
		this.gun = gun;
		this.damager = damager;
		this.damage = damage;
	}

	/**
	 * 获取开枪的人
	 * 
	 * @return 伤害者
	 */
	public Player getDamager() {
		return this.damager;
	}

	/**
	 * 获取枪的实例
	 * 
	 * @return 枪
	 */
	public Gun getGun() {
		return this.gun;
	}

	/**
	 * 获取伤害值
	 * 
	 * @return 伤害值
	 */
	public double getDamage() {
		return this.damage;
	}

	/**
	 * 获取被害者
	 * 
	 * @return 被害者
	 */
	public Entity getEntity() {
		return this.entity;
	}

	/**
	 * 重新定义伤害
	 * 
	 * @param i
	 *            伤害
	 */
	public void setDamage(int i) {
		this.damage = i;
	}

	@Override
	public HandlerList getHandlers() {
		return handlers;
	}

	public static HandlerList getHandlerList() {
		return handlers;
	}

	/**
	 * 事件是否被取消
	 */
	@Override
	public boolean isCancelled() {
		return this.isCanceled;
	}

	/**
	 * 设置取消事件
	 */
	@Override
	public void setCancelled(boolean arg0) {
		this.isCanceled = arg0;
	}

}
